package com.fire.control.system.support.util;

import java.security.MessageDigest;

import org.springframework.stereotype.Component;

import sun.misc.BASE64Encoder;

@Component
public class MD5Util {
	//获得md5字符串
	public String getMD5Str(String str){
		String newstr = null;
		try{
			//确定计算方法
	        MessageDigest md5=MessageDigest.getInstance("MD5");
	        BASE64Encoder base64en = new BASE64Encoder();
	        //加密后的字符串
	        newstr=base64en.encode(md5.digest(str.getBytes("utf-8")));
		}catch(Exception e){
			e.printStackTrace();
		}
		 return newstr;
	}
}
